﻿using System;
using System.Collections.Generic;
using System.Text;
using HeThongDAO;
using System.Data;
using System.Data.OleDb;
using DTO;

namespace HeThongBUS
{
    public class SachBUS
    {
        public static DataTable LayTatCaSach()
        {
            return HeThongDAO.SachDAO.SelectAll();
        }
        public static DataTable ChonSach(SachDTO sa)
        {
            return SachDAO.ChonSach(sa);
        }
        public static DataTable LayTheLoai_Sach(int masach)
        {
            return HeThongDAO.SachDAO.LayTheLoai_Sach(masach);
        }
        public static DataTable LayTacGia_Sach(int masach)
        {
            return HeThongDAO.SachDAO.LayTacGia_Sach(masach);
        }

        public static DataTable TraCuuSach_TacGia_TheLoai(int MaTacGiaTraCuu, int MaTheLoaiTraCuu)
        {
            return HeThongDAO.SachDAO.TraCuuSach_TacGia_TheLoai(MaTacGiaTraCuu, MaTheLoaiTraCuu);
        }

        public static DataTable TraCuuSach(string TenSachTraCuu, string TenTacGiaTraCuu, string TenTheLoaiTraCuu, bool TenSachChecked, bool TacGiaChecked, bool TheLoaiChecked)
        {
            if(TenSachChecked || TacGiaChecked || TheLoaiChecked)
                return HeThongDAO.SachDAO.TraCuuSach(TenSachTraCuu, TenTacGiaTraCuu, TenTheLoaiTraCuu, TenSachChecked, TacGiaChecked, TheLoaiChecked);

            DataTable dt = new DataTable();

            return dt;
        }

        public static DataTable TraCuuSach_DuyHung(string ten_sach, int ma_the_loai, int ma_tac_gia, bool ten_sach_chk, bool the_loai_chk, bool tac_gia_chk)
        {
            if (ten_sach_chk || the_loai_chk || tac_gia_chk)
                return HeThongDAO.SachDAO.TraCuuSach_DuyHung(ten_sach,ma_the_loai,ma_tac_gia,ten_sach_chk,the_loai_chk,tac_gia_chk);     
            DataTable dt = new DataTable();
            return dt;
        }
        public static void ThemSach(SachDTO sa)
        {
            SachDAO.ThemSach(sa);
        }
        public static void CapNhatBang(DataTable dt, string ten_bang)
        {
            SachDAO.CapNhatBang(dt, ten_bang);
        }
        public static void XoaSach(SachDTO sa)
        {
            SachDAO.XoaSach(sa);
        }
        public static void CapNhatSach(SachDTO sa)
        {
            SachDAO.CapNhatSach(sa);
        }

        // Xuan huy
        public static void CapNhatSLTonSach(SachDTO sa)
        {
            SachDAO.CapNhatSLTonSach(sa);
        }
        public static DataTable LayTongBanTuThang(SachDTO sa, int thang,int nam)
        {
            return SachDAO.LayTongBanTuThang(sa, thang, nam);
        }
        public static DataTable LayTongNhapTuThang(SachDTO sa, int thang, int nam)
        {
            return SachDAO.LayTongNhapTuThang(sa, thang, nam);
        }
        public static DataTable LayTongNhapTrongThang(SachDTO sa, int thang, int nam)
        {
            return SachDAO.LayTongNhapTrongThang(sa, thang, nam);
        }
        public static DataTable LayTongBanTrongThang(SachDTO sa, int thang, int nam)
        {
            return SachDAO.LayTongBanTrongThang(sa, thang, nam);
        }
        public static void test()
        {
            SachDAO.test();
        }
    }
}
